package com.trial.eyefollowupapp.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.TextUnitType
import androidx.compose.ui.unit.dp

// 定义应用的颜色方案
private val LightColorScheme = lightColorScheme(
    primary = Color(0xFF1E88E5),
    secondary = Color(0xFF00C853),
    tertiary = Color(0xFFF57C00),
    background = Color(0xFFF9F9F9),
    surface = Color(0xFFFFFFFF),
    error = Color(0xFFD32F2F),
    onPrimary = Color(0xFFFFFFFF),
    onSecondary = Color(0xFFFFFFFF),
    onTertiary = Color(0xFFFFFFFF),
    onBackground = Color(0xFF121212),
    onSurface = Color(0xFF121212),
    onError = Color(0xFFFFFFFF),
)

private val DarkColorScheme = darkColorScheme(
    primary = Color(0xFF64B5F6),
    secondary = Color(0xFF66BB6A),
    tertiary = Color(0xFFFFB74D),
    background = Color(0xFF121212),
    surface = Color(0xFF1E1E1E),
    error = Color(0xFFEF5350),
    onPrimary = Color(0xFF000000),
    onSecondary = Color(0xFF000000),
    onTertiary = Color(0xFF000000),
    onBackground = Color(0xFFFFFFFF),
    onSurface = Color(0xFFFFFFFF),
    onError = Color(0xFFFFFFFF),
)

// 定义应用的排版方案 - 修复版
val AppTypography = Typography(
    bodyLarge = TextStyle(
        fontSize = TextUnit(16f, TextUnitType.Sp),
        fontFamily = FontFamily.Default,
        lineHeight = TextUnit(1.6f, TextUnitType.Sp)
    ),
    titleMedium = TextStyle(
        fontSize = TextUnit(18f, TextUnitType.Sp),
        fontFamily = FontFamily.Default
    ),
    titleSmall = TextStyle(
        fontSize = TextUnit(14f, TextUnitType.Sp),
        fontFamily = FontFamily.Default
    ),
    bodyMedium = TextStyle(
        fontSize = TextUnit(14f, TextUnitType.Sp),
        fontFamily = FontFamily.Default
    ),
    headlineLarge = TextStyle(
        fontSize = TextUnit(24f, TextUnitType.Sp),
        fontWeight = FontWeight.Bold,
        fontFamily = FontFamily.Default
    ),
    titleLarge = TextStyle(
        fontSize = TextUnit(20f, TextUnitType.Sp),
        fontWeight = FontWeight.SemiBold,
        fontFamily = FontFamily.Default
    )
)

// 应用主题
@Composable
fun EyeFollowUpAppTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),
    content: @Composable () -> Unit
) {
    val colorScheme = if (darkTheme) DarkColorScheme else LightColorScheme

    MaterialTheme(
        colorScheme = colorScheme,
        typography = AppTypography,
        content = content
    )
}

// 定义常用的尺寸常量
object AppDimens {
    val spacingSmall = 8.dp
    val spacingMedium = 16.dp
    val spacingLarge = 24.dp
    val spacingXLarge = 32.dp
    val cornerRadiusSmall = 8.dp
    val cornerRadiusMedium = 12.dp
    val cornerRadiusLarge = 16.dp
    val elevationSmall = 2.dp
    val elevationMedium = 4.dp
    val elevationLarge = 8.dp
}

// 定义动画常量
object AppAnimations {
    const val durationShort = 200
    const val durationMedium = 300
    const val durationLong = 500
}